package com.aegean.MonitorExamSYS.center.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.center.business.CenterBusiness;
import com.aegean.MonitorExamSYS.center.component.ConductionInfoForExaminee;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ShowConductionForExaminee")
@Scope("prototype")
public class ShowConductionForExaminee extends ActionSupport implements
		ServletRequestAware {
	private HttpServletRequest request;
	private HttpSession session;
	@Resource
	CenterBusiness business;
	private List<ConductionInfoForExaminee> conductions;
	private int total;
	private int exam_Id;

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getExam_Id() {
		return exam_Id;
	}

	public void setExam_Id(int exam_Id) {
		this.exam_Id = exam_Id;
	}
    
	public List<ConductionInfoForExaminee> getConductions() {
		return conductions;
	}

	public void setConductions(List<ConductionInfoForExaminee> conductions) {
		this.conductions = conductions;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		conductions = business.showConductionListForExaminee(exam_Id);
		if (conductions == null || conductions.size() == 0) {
			total = 0;
		} else {
			total = conductions.size();
			session.setAttribute("ConductionsForExaminee",conductions);
		}
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
		this.session = request.getSession();

	}
}
